home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / msgcat.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  3.5 KB  |  116 lines

  1. #
  2. # msgcat.test
  3. #
  4. # Tests for the XPG/3 message catalog commands.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: msgcat.test,v 2.0 1992/10/16 04:50:04 markd Rel $
  16. #------------------------------------------------------------------------------
  17.  
  18. if {[info procs test] != "test"} then {source testlib.tcl}
  19.  
  20. #
  21. # This only tests default strings, since its difficult to setup and rely on
  22. # a message catalog being present.  This will work on systems without message
  23. # catalogs, as the stubs return default strings.
  24. #
  25.  
  26. test message-cat-1.1 {catopen tests} {
  27.     set msgcat [catopen "FOOBAZWAP"]
  28.     catclose $msgcat 
  29.     crange $msgcat 0 5
  30. } {msgcat}
  31.  
  32.  
  33. test message-cat-1.2 {catopen tests} {
  34.     set msgcat [catopen -nofail "FOOBAZWAP"]
  35.     catclose $msgcat 
  36.     crange $msgcat 0 5
  37. } {msgcat}
  38.  
  39.  
  40. test message-cat-1.3 {catopen tests} {
  41.     list [catch {catopen -fail "FOOBAZWAP"} msg] $msg
  42.     case $msg {
  43.         {"open of message catalog failed"} {concat "OK"}
  44.         {"the message catalog facility is not available, default string is always returned"} {concat "OK"}
  45.         default {concat "BAD"}
  46.     }
  47. } {OK}
  48.  
  49. test message-cat-2.1 {catclose tests} {
  50.     set msgcat [catopen "FOOBAZWAP"]
  51.     catclose $msgcat 
  52.     list [catch {catgets $msgcat} msg] $msg
  53. } {1 {catgets catHandle setnum msgnum defaultstr}}
  54.  
  55.  
  56. test message-cat-2.2 {catclose tests} {
  57.     set msgcat [catopen "FOOBAZWAP"]
  58.     catch {catclose $msgcat}
  59. } {0}
  60.  
  61. test message-cat-2.3 {catclose tests} {
  62.     set msgcat [catopen "FOOBAZWAP"]
  63.     catch {catclose -nofail $msgcat}
  64. } {0}
  65.  
  66. test message-cat-2.4 {catclose tests} {
  67.     set msgcat [catopen "FOOBAZWAP"]
  68.     catclose $msgcat 
  69.     list [catch {catclose -fail $msgcat} msg] $msg
  70. } {1 {msgcat is not open}}
  71.  
  72.  
  73. test message-cat-2.5 {catclose tests} {
  74.     list [catch {catclose baz} msg] $msg
  75. } {1 {invalid msgcat handle: baz}}
  76.  
  77. test message-cat-2.6 {catclose tests} {
  78.     list [catch {catclose} msg] $msg
  79. } {1 {catclose [-fail|-nofail] catHandle}}
  80.  
  81.  
  82. test message-cat-3.1 {catgets tests} {
  83.     set msgcat [catopen "FOOBAZWAP"]
  84.     set msg [catgets $msgcat 1 12 "This is a test"]
  85.     catclose $msgcat 
  86.     set msg
  87. } {This is a test}
  88.  
  89. test message-cat-3.2 {catgets tests} {
  90.     set msgcat [catopen "FOOBAZWAP"]
  91.     set msg [catgets $msgcat 101 12 "This is an actual emergency"]
  92.     catclose $msgcat 
  93.     set msg
  94. } {This is an actual emergency}
  95.  
  96. test message-cat-3.3 {catgets tests} {
  97.     set msgcat [catopen "FOOBAZWAP"]
  98.     catclose $msgcat 
  99.     list [catch {catgets $msgcat 101 12 "This is an actual emergency"} msg] $msg
  100. } {1 {msgcat is not open}}
  101.  
  102. test message-cat-3.4 {catgets tests} {
  103.     set msgcat [catopen "FOOBAZWAP"]
  104.     set out [list [catch {catgets $msgcat xx 12 "This is an actual emergency"} msg] $msg]
  105.     catclose $msgcat
  106.     set out
  107. } {1 {expected integer but got "xx"}}
  108.  
  109. test message-cat-3.5 {catgets tests} {
  110.     set msgcat [catopen "FOOBAZWAP"]
  111.     set out [list [catch {catgets $msgcat 102 "This is an actual emergency"} msg] $msg]
  112.     catclose $msgcat
  113.     set out
  114. } {1 {catgets catHandle setnum msgnum defaultstr}}
  115.  
  116.